package main

import "fmt"

func countBits(n int) []int {
	arr := []int{}
	for i := 0; i <= n; i++ {
		str := fmt.Sprintf("%b", i)
		count := 0
		for j := 0; j < len(str); j++ {
			if str[j] == '1' {
				count++
			}
		}
		arr = append(arr, count)
	}
	return arr
}
func main() {
	fmt.Println(countBits(5))
}
